module.exports = `
  enum Source {
    wexin
    user
  }
  enum GroupState {
    normal
    disbanded
  }

  type Member {
    id: Int!
    groupId: Int!
    userId: Int!
    relateId: Int
    role: String!
    roleName: String
    name: String
    nickName: String
    avatarUrl: String
    createdAt: String
    updatedAt: String
  }

  type Group {
    id: ID!
    source: Source
    state: GroupState
    name: String
    avatarUrl: String
    ownerId: Int
    owner: User
    openGroupId: String
    createdAt: String
    users: [User]
    members: [Member]
  }

  type PageModalGroup implements Page{
    totalCount: Int
    hasMore: Boolean
    totalPages: Int
    pageIndex: Int
    pageSize: Int
    rows: [Group]
  }

  extend type Query {
    # 通过ID 获取班级(群)信息
    group(id: ID): Group
    # 列出所有班级列表
    allGroups(pageIndex: Int = 0, pageSize: Int = 20): PageModalGroup
    # 列出当前用户所在的班级列表
    groups(pageIndex: Int = 0, pageSize: Int = 20): PageModalGroup
    # 列出当前用户所创建的班级
    groupMys: [Group]

    # 列出与我有关的群组
    groupMyRelates: [Group]

    # 我的组信息
    groupMyGroupInfo(groupId: Int!): Member
  }

  extend type Mutation {
    # 创建群组
    groupCreate(name: String!): Group

    # 修改群组
    groupModify(groupId: Int!, name: String!): Group

    # 修改会员信息
    groupModifyMemberInfo(groupId: Int!, name: String!): Boolean

    # 移除会员
    groupRemoveMembersByIds(groupId: Int!, memberIds: [Int!]!): Boolean

    # 解散群组
    groupDisband(groupId: Int!): Boolean

    # 加入群组
    groupJoin(groupId: Int!, name: String!, role: String!): Boolean

    # 解密微信群信息，获取openGId，并通过作业加入班级(群)
    wxGroupInfo(encryptedData: String!, iv: String!, groupOwnerId: Int): Group

    openGId: String

    generateAvatar(id: ID!): String
  }
`
